package vip.liux.contracts.infrastructure.localmsg;

import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;


@Setter
@Getter
public class LocalMessageRecord {

    private String id;
    private String reqSnapshot;
    private String status;
    private Long nextRetryTime;
    private Integer retryTimes;
    private Integer maxRetryTimes;
    private String failReason;
    private LocalDateTime creationTime;
    private LocalDateTime lastModificationTime;

    public LocalMessageRecord() {
    }

    public LocalMessageRecord(String reqSnapshot, Integer maxRetryTimes, Long nextRetryTime) {
        this.status = TaskStatus.INIT.name();
        this.reqSnapshot = reqSnapshot;
        this.maxRetryTimes = maxRetryTimes;
        this.nextRetryTime = nextRetryTime;
        this.retryTimes = 0;
        this.creationTime = LocalDateTime.now();
    }

    public enum TaskStatus {INIT, SUCCESS, FAIL, RETRY}
}
